package com.frank.libandroid;

import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

public class ReflectUtil {

    public static Type getGeneric(Object object, int index) {
        Type superclass = object.getClass().getGenericSuperclass();
        if (superclass instanceof ParameterizedType) {
            Type[] types = ((ParameterizedType) superclass).getActualTypeArguments();
            if (types != null && types.length > index) {
                return types[index];
            }
        }
        return null;
    }
}
